﻿
Namespace PL.CoreSDK
    Public Class Equipment_PL
        Inherits PLBase

        Public Sub New()
            MyBase.New()
        End Sub


		Public Sub New(ByVal queryName As String)
			MyBase.New(queryName)
		End Sub

		Sub OnRowUpdating(ByVal sender As Object, ByVal e As SqlRowUpdatingEventArgs) Handles MetaDataTable.OnRowUpdating
		End Sub

		Public Overrides Function Delete() As Boolean
			'Throw New NotImplementedException("Delete To Come...")
			Return False
		End Function

		Public Overrides Function Validate() As Boolean
			'Throw New NotImplementedException("Validate To Come...")
			Return True
        End Function

        ''' <summary>
        ''' Validate a Equipment DataRow
        ''' </summary>
        ''' <param name="row"></param>
        ''' <remarks>Errors are saved with row.SetColumnError method</remarks>
        Public Overrides Sub ValidateRow(row As DataRow)
            row.ClearErrors()

            If row.Table.Columns.Contains("EquipmentCd") Then
                If IsDBNull(row("EquipmentCd")) Then
                    row.SetColumnError("EquipmentCd", "Mandatory")
                End If
            End If

            If row.Table.Columns.Contains("EquipmentDescr_PRM") Then
                If IsDBNull(row("EquipmentDescr_PRM")) Then
                    row.SetColumnError("EquipmentDescr_PRM", "Mandatory")
                End If
            End If

            If row.Table.Columns.Contains("EquipmentDescr_ALT") Then
                If IsDBNull(row("EquipmentDescr_ALT")) Then
                    row.SetColumnError("EquipmentDescr_ALT", "Mandatory")
                End If
            End If

            If row.Table.Columns.Contains("AmortRate") Then
                If IsDBNull(row("AmortRate")) Then
                    row.SetColumnError("AmortRate", "Mandatory")
                End If
            End If

            If row.Table.Columns.Contains("InspectionRate") Then
                If IsDBNull(row("InspectionRate")) Then
                    row.SetColumnError("InspectionRate", "Mandatory")
                End If
            End If

            If row.Table.Columns.Contains("Capacity") Then
                If IsDBNull(row("Capacity")) Then
                    row.SetColumnError("Capacity", "Mandatory")
                End If
            End If

            If row.HasErrors Then
                row.RowError = "Please check your columns, a validation error occur"
            End If
        End Sub

    End Class
End Namespace
